home *** CD-ROM | disk | FTP | other *** search
- #ifndef __BF_H__
- #define __BF_H__
- /*
- * $RCSfile: bf.h,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:19 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "forward.h"
- #include "resources.h"
- #include "error.h"
- #include "io.h"
- #include "object.h"
- #include "tid.h"
- #include "bf_macro.h"
-
- /* BEGIN visible to E interpreter */
-
- /*
- * bf.h
- * Global defines, typedefs, etc. for the buffer manager.
- */
-
-
- /*
- * Next, the definition for page info structures.
- */
- typedef struct PageInfo {
-
- int bufIndex; /* index of page in BufTable */
- TWO blockCount; /* number of blocks in this page */
- char *bufFrame; /* address of page in buffer pool */
- LIST userList; /* list of page user descriptors */
- PAGEHASH *pageHash; /* pointer to the hash structure */
- BUFINFO *bufInfo;
-
- } PAGEINFO;
-
-
-
- /* END visible to E interpreter */
-
- #include "PAGEHASH.h"
-
-
- /*
- * define intent modes passed to bf_ReadPage and its descendents
- */
- #define INTENT_READ 1
- #define INTENT_WRITE 2
-
-
- /* BEGIN visible to E interpreter */
-
- /*
- * Definition for the BufGroup table.
- * Buffer groups are used to implement a DBMIN-like replacement strategy.
- * There are two lists associated with a buffer group, the group's
- * fixed list and the groups unfixed list.
- *
- * No fixed list is kept.
- * The group's unfixed list is organized as a true list so that
- * different replacement policies can be used.
- * Note that a buffer region can simultaneously reside in several
- * fixed lists but never in more than one unfixed list.
- */
- typedef struct BufGroup {
-
- ONE flags; /* state flags of group */
- ONE replacePolicy; /* replacement policy for unfixed pages */
- TWO index; /* index of this group structure */
- int maxCharges; /* max charges allotted to the group */
- int fixedCharges; /* current fixed charges */
- int unfixedCharges; /* current unfixed charges */
- LIST fixedList; /* queue of fixed elements */
- LIST unfixedList; /* queue of unfixed elements */
- LISTELEMENT groupList; /* used for free/used lists */
- LISTELEMENT transList; /* hangs off the transaction record */
-
- MAGIC magic; /* magic number for structure verify */
- } BUFGROUP;
-
-
- #define BUFGROUP_MAGIC 0xef401cad
-
- /* END visible to E interpreter */
-
- /* BEGIN visible to user */
-
- /*
- * Definition of flags for buffer groups
- */
- #define G_FREE 0x0
- #define G_OPEN 0x1
- #define G_TRANS 0x2
-
- /* added for client operation logging - MJF */
- #define LOG_GROUP 0x4
- #define FORCE_GROUP 0x8
-
- /* END visible to user */
-
- /* BEGIN visible to E interpreter */
-
- /*
- * Definition of the entry to record
- */
- typedef struct GroupLink {
-
- TWO type; /* flags field */
- TWO fixedCount; /* number of times fixed in group */
- LISTELEMENT hashList; /* hung off list of structures */
- LISTELEMENT groupList; /* member of buffer group */
- PAGEHASH *pageHash; /* pointer to hash structure */
- BUFGROUP *bufGroup; /* pointer to the buffer group */
- char *bufFrame; /* pointer to the actual data */
-
- MAGIC magic; /* for verification */
-
- } GROUPLINK;
-
- /*
- * define magic number
- */
- #define GROUPLINK_MAGIC 0xbe4a20c8
-
- /*
- * Flag that indicates this is a group link for a page
- */
- #define TYPE_FREE 0x0 /* neither */
- #define TYPE_PAGE 0x1
- #define TYPE_CHUNK 0x2
-
- /* END visible to E interpreter */
-
- /*
- * Return values for the buffer groups
- */
- #define BF_NOT_PRESENT 0
- #define BF_FREE 1
- #define BF_OTHER 2
- #define BF_FIXED 3
- #define BF_UNFIXED 4
-
-
- /* BEGIN visible to user */
- /*
- * Buffer replacement policies for buffer groups.
- */
- #define BF_DEFAULT 0
- #define BF_LRU 1
- #define BF_MRU 2
- /* END visible to user */
-
-
- /*
- * Define some flags for use in the bf layer
- * These are for the BFFLAGS type.
- */
-
- #define BF_SEM 0x100
- #define BF_NOREAD 0x200
- #define BF_FORCE 0x400
- #define BF_WAIT 0x800
-
- /* BEGIN visible to user */
- typedef struct UserDesc {
-
- char *basePtr; /* ptr user will use to access data */
- int byteCount; /* bytes accessible to user */
- int objectSize; /* size of object */
- TWO userFlags; /* properties field of the obj header */
- TWO type;
- TWO flags; /* if this descriptor is valid */
- TWO tag; /* tag field from obj hdr */
- OID oid; /* oid of object being referenced */
- /* END visible to user */
- /* BEGIN visible to E interpreter */
- GROUPLINK *groupLink; /* ptr to the page's hash entry */
- BUFGROUP *bufGroup;
- char *objInfo; /* pointer to page info structure */
- TWO objectSlot;
- LISTELEMENT userList; /* list of page users */
- LISTELEMENT oidList;
- LISTELEMENT transList; /* hung off the transaction record */
- FID fid;
- int offset; /* starting offset of bytes in object */
- OID forwardOid; /* oid of the forwarded portion - if any*/
-
-
- MAGIC magic; /* data structure magic verification */
- /* END visible to E interpreter */
-
- /* BEGIN visible to user */
- } USERDESC;
- /* END visible to user */
-
-
- /*
- * define magic number for page user descriptor
- */
- #define USERDESC_MAGIC 0x54cae09a
-
-
- /*
- * Define flags for user descriptors
- */
- #define USERDESC_FREE 0x0
- #define USERDESC_VALID 0x1
- #define USERDESC_DESTROYED 0x2
-
-
- #define SET_PAGEHASHLOCK(p, m) { \
- if (m == EX) { \
- p->writeLock = TransRec.clientTid; \
- p->readLock = TransRec.clientTid; \
- } \
- else if (m == SH) { \
- p->writeLock = NULL_TID; \
- p->readLock = TransRec.clientTid; \
- } \
- else { \
- p->writeLock = NULL_TID; \
- p->readLock = NULL_TID; \
- } \
- }
-
- /* include these so that TransRec is defined: */
- #include "trans.h"
- #include "trans_globals.h"
-
- #define GET_PAGEHASHLOCK(p, m) {\
- m = (p->writeLock == TransRec.clientTid) ? EX : \
- ((p->readLock == TransRec.clientTid) ? SH : NL); \
- }
-
-
- #define UNLOCKABLE_PAGE (H_INDEX)
-
- #endif __BF_H__
-